package com.itheima.dao;

import com.itheima.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.*;
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
import org.springframework.data.jpa.repository.JpaRepository;


@Mapper
public interface UserDao  {

    @Select("Select * from user where username=#{username}")
    User findUserByUsername(String username);

    @Update("update user set name=#{name},age=#{age},phone=#{phone} where id=#{id}")
    void ChangeMessage(@Param("id") Integer id, @Param("name") String name, @Param("age") Integer age, @Param("phone") String phone);

    @Update("update user set password = #{password} where id=#{id}")
    void ChangePassword(@Param("password") String password,@Param("id") Integer id);

    @Select("select * from user where id =#{id}")
    User findMessageById(Integer id);

    @Update("update user set password = #{password} where username=#{username}")
    void updatePassword(@Param("password") String password,@Param("username")String username);

    @Insert("insert into user(username,password,phone) values(#{username},#{password},#{phone})")
    void save(@Param("username") String username,@Param("password") String password,@Param("phone") String phone);


}
